﻿using FastExecutor.Base.Design;
using FastExecutor.Base.Util;
using FastExecutor.ORG.Entity;
using FastIOC.Annotation;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FastExecutor.ORG.DB
{
    public class DB_CodeItem : FastTemplateDB<Frame_CodeItem>
    {
        [AutoWired]
        private DB_CodeMain @DB_CodeMain;
        public override void Insert(Frame_CodeItem Entity)
        {
            Entity.RowGuid = CommonUtil.CreateCommonGuid();
            Entity.AddDate = DateTime.Now;
            base.Insert(Entity);
        }

        public List<Frame_CodeItem> FindCodeItemList(string CodeName)
        {
            List<Frame_CodeMain> CodeMainList = @DB_CodeMain.FindAll(string.Format(" and CodeName='{0}'", CodeName));
            if (CodeMainList.Count>0)
            {
                return base.FindAll(string.Format(" and MainGuid='{0}'", CodeMainList[0].RowGuid));
            }
            else
            {
                return new List<Frame_CodeItem>();
            }
            
        }
    }
}
